import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树
export function getPage(queryParams) {
    const data = {
        ascriptionId: store.state.userInfo.ascriptionId,
        currentPage: queryParams.currentPage,
        pagesize: queryParams.pagesize
    }
    return request({
        url: '/getExaminationtasksPage',
        method: 'post',
        data: data
    })
}

// 数据列表
export function listData(queryParams) {
    const data = {
        ascriptionId: store.state.userInfo.ascriptionId,
        currentPage: queryParams.currentPage,
        pagesize: queryParams.pagesize,
        keywords: queryParams.keywords,
        category: queryParams.category, //考试分类 id
        examMode: queryParams.examMode, //考试方式 id
        examLevel: queryParams.examLevel, //考试级别 id
        examPlace: queryParams.examPlace, //考试地点 id
        department: queryParams.department, //考试部门 id
        startTime: queryParams.startTime, //考试开始时间
        endTime: queryParams.endTime, //考试结束时间
        taskType: queryParams.taskType, //区分发布考试1 和 课程考试2
    }
    return request({
        url: '/getExaminationtasksList',
        method: 'post',
        data: data
    })
}

// 新增
export function addData(val) {
    const data = {
        projectContent: {
            ascriptionId: store.state.userInfo.ascriptionId, //机构 id
            title: val.title, //考试名称
            typeId: val.typeId, //考试类型 id
            typeVal: val.typeVal, //考试类型
            levelId: val.levelId, //考试级别 id
            levelVal: val.levelVal, //考试级别
            examModeId: val.examModeId, //考试方式 id
            examMode: val.examMode, //考试方式
            departmentId: val.departmentId, //考试部门 id
            department: val.department, //考试部门
            paperId: val.paperId, //考试试卷 id
            paper: val.paper, //考试试卷
            shiftId: val.shiftId, //考试班组 id
            shift: val.shift, //考试班组
            personnelIds: val.personnelIds, //参加考试人员名单id列表
            personnelNames: val.personnelNames, //参加考试人员名单（格式：部门-姓名）
            personnelNum: val.personnelNum, //参加考试人数
            source: val.source, //考试任务来源 1-培训任务附加 2-独立考试
            trainingtaskId: val.trainingtaskId, //考试任务id，独立考试时为0
            trainingtask: val.trainingtask, //考试任务名称，独立考试时为空值
            frequency: val.frequency, //允许考试次数 0-不限次数
            placeId: val.placeId, //考试地点 id
            place: val.place, //考试地点
            thePic: val.thePic, //考试封面图片
            introduction: val.introduction, //考试简介
            instructions: val.instructions, //考试须知
            startTime: val.startTime, //考试开始时间
            endTime: val.endTime, //考试结束时间
        }
    }
    return request({
        url: '/addExaminationtasks',
        method: 'post',
        data: data
    })
}

// 获取单条数据
export function getData(theid) {
    const data = {
        theid
    }
    return request({
        url: '/getExaminationtasksData',
        method: 'post',
        data: data
    })
}

// 修改
export function updateData(val) {
    const data = {
        projectContent: {
            theid: val.theid, //id
            title: val.title, //考试名称
            typeId: val.typeId, //考试类型 id
            typeVal: val.typeVal, //考试类型
            levelId: val.levelId, //考试级别 id
            levelVal: val.levelVal, //考试级别
            examModeId: val.examModeId, //考试方式 id
            examMode: val.examMode, //考试方式
            departmentId: val.departmentId, //考试部门 id
            department: val.department, //考试部门
            paperId: val.paperId, //考试试卷 id
            paper: val.paper, //考试试卷
            shiftId: val.shiftId, //考试班组 id
            shift: val.shift, //考试班组
            personnelIds: val.personnelIds, //参加考试人员名单id列表
            personnelNames: val.personnelNames, //参加考试人员名单（格式：部门-姓名）
            personnelNum: val.personnelNum, //参加考试人数
            source: val.source, //考试任务来源 1-培训任务附加 2-独立考试
            trainingtaskId: val.trainingtaskId, //考试任务id，独立考试时为0
            trainingtask: val.trainingtask, //考试任务名称，独立考试时为空值
            frequency: val.frequency, //允许考试次数 0-不限次数
            placeId: val.placeId, //考试地点 id
            place: val.place, //考试地点
            thePic: val.thePic, //考试封面图片
            introduction: val.introduction, //考试简介
            instructions: val.instructions, //考试须知
            startTime: val.startTime, //考试开始时间
            endTime: val.endTime, //考试结束时间
        }
    }
    return request({
        url: '/updateExaminationtasks',
        method: 'post',
        data: data
    })
}

// 删除
export function delData(theid) {
    const data = {
        theid
    }
    return request({
        url: '/delExaminationtasks',
        method: 'post',
        data: data
    })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
    const data = {
        idListStr
    }
    return request({
        url: '/delMultipleExaminationtasks',
        method: 'post',
        data: data
    })
}



// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(theid, enable) {
    const data = {
        projectContent: {
            theid,
            enable
        }
    }
    return request({
        url: '/changeEnableExaminationtasks',
        method: 'post',
        data: data
    })
}
// --------------------------------------------------------------------------？
// 下拉框
export function getSelect() {
    const data = {
        ascriptionId: store.state.userInfo.ascriptionId,
    }
    return request({
        url: '/getExaminationComboBox',
        method: 'post',
        data: data
    })
}
//table表格获取
export function getTableList(tabledata) {
    // const data = {
    //     ascriptionId
    // }
    tabledata.ascriptionId = store.state.userInfo.ascriptionId
    return request({
        url: '/getExaminationList',
        method: 'post',
        data: tabledata
    })
}
//table表格单条数据获取
export function getItem(data) {
    return request({
        url: '/getExaminationData',
        method: 'post',
        data: data
    })
}

// 考试统计
export function getTestInfo(theid) {
    const data = {
        theid  //培训记录id
    }
    return request({
        url: '/getExamStatistics',
        method: 'post',
        data: data
    })
}

// 班组名称弹框
export function getCrewpopel(queryParams) {
    const data = {
        examTaskId: queryParams.theid,  //考试任务id
        currentPage: queryParams.currentPage,
        pagesize: queryParams.pagesize
    }
    return request({
      url: '/getPersonnelListExamination',
      method: 'post',
      data: data
    })
}


// 查看试卷 已考
export function getExamRecordPaper(examinationId) {
    const data = {
        examinationId,  //考试记录id
    }
    return request({
      url: '/getExamRecordTestPaper',
      method: 'post',
      data: data
    })
}